def printBoard(board):
    for ls in board:
        for x in ls:
            print("%3d"%(x), end="", sep="")
        print()

def getPos(pos, r, c):
    if pos > r * c:
        return (-1, -1)
    return ((pos-1) // c, (pos-1) % c)

dxy = [[],
    [(0,1),(0,2)],
    [(1,0),(2,0)],
    [(-1,0),(-2,0)],
    [(1,0),(1,1)],
    [(0,1),(1,1),(2,1)],
    [(0,1),(1,1),(1,2)]]

dxyl = [[],
        [(0,-1),(0,-2)],
        [(1,0),(2,0)],
        [(-1,0),(-2,0)],
        [(0,-1),(-1,-1)],
        [(-1,0),(-2,0),(-2,-1)],
        [(0,-1),(-1,-1),(-1, -2)]]

N = 6

def isOKRight(shape, board, x, y):
    def isInRange(x,y):
        if 0 <= x < len(board) and 0 <= y < len(board[0]):
            return True
        return False
    if board[x][y] != 0:
        return False
    if y == 0:
        ls = dxy[shape]
        for dpos in ls:
            dx, dy = dpos
            if isInRange(x+dx, y+dy) and board[x+dx][y+dy] != 0:
                return (-1, -1)
        return x+ls[len(ls)-1][0], y+ls[len(ls)-1][1]
    else:
        ls = dxy[shape]
        for dpos in ls:
            dx, dy = dpos
            if (not isInRange(x+dx, y+dy)) or (board[x+dx][y+dy] != 0):
                return (-1, -1)
            if dy == 0:
                if not isInRange(x+dx, y-1):
                    continue
                if board[x+dx][y-1] > 0:
                    return (-1, -1)

        return x+ls[len(ls)-1][0], y+ls[len(ls)-1][1]
    pass
def isOKLeft(shape, board, x, y):
    def isInRange(x,y):
        if 0 <= x < len(board) and 0 <= y < len(board[0]):
            return True
        return False
    if board[x][y] != 0:
        return False
    if y == c-1:
        ls = dxyl[shape]
        for dpos in ls:
            dx, dy = dpos
            if (not isInRange(x+dx, y+dy)) or (board[x+dx][y+dy] != 0):
                return (-1, -1)
        return x+ls[len(ls)-1][0], y+ls[len(ls)-1][1]
    else:
        ls = dxyl[shape]
        for dpos in ls:
            dx, dy = dpos
            if (not isInRange(x+dx, y+dy)) or (board[x+dx][y+dy] != 0):
                return (-1, -1)
            if dy == 0:
                if not isInRange(x+dx, y+1):
                    continue
                if board[x+dx][y+1] > 0:
                    return (-1, -1)
        return x+ls[len(ls)-1][0], y+ls[len(ls)-1][1]



for TEST_CASE in range(5):
    ans = ""
    CHARMAP = "!ABBCDE"
    cur_shape = 1
    r, c, s, n, posstr = input().split(" ", maxsplit=4)
    r, c, s, n = map(int, (r, c, s, n))
    poss = map(int, posstr.split())
    board = [[0 for _ in range(c)] for _ in range(r)]
    # 0 -> empty
    # -1 -> unavailable
    # x -> occupied, where x in [1,2,3,4,5,6]
    for x in poss:
        i, j = getPos(x, r, c)
        board[i][j] = -1
    curx, cury = getPos(s, r, c)
    if s % c == 0: # right-to-left
        while cury != -1:
            if cury == c-1 and (cur_shape == 2 or cur_shape == 3):
                cur_shape = (cur_shape) % N + 1 # next shape
                continue
            nx, ny = isOKLeft(cur_shape, board, curx, cury)
            if nx == -1 and ny == -1:
                # print("Skipping")
                cur_shape = (cur_shape) % N + 1 # next shape
                continue
            board[curx][cury] = cur_shape
            for ddxy in dxyl[cur_shape]:
                dx, dy = ddxy
                board[curx+dx][cury+dy] = cur_shape
            curx, cury = nx, ny-1
            ans += CHARMAP[cur_shape]
            # print(curx,cury)
            # printBoard(board)
            # print("----------------------------------")
            cur_shape = (cur_shape) % 6 + 1 # next shape
        pass
    else:          # left-to-right
        while cury != c:
            if cury == 0 and (cur_shape == 2 or cur_shape == 3):
                cur_shape = (cur_shape) % N + 1 # next shape
                continue
            nx, ny = isOKRight(cur_shape, board, curx, cury)
            if nx == -1 and ny == -1:
                cur_shape = (cur_shape) % N + 1 # next shape
                continue
            board[curx][cury] = cur_shape
            for ddxy in dxy[cur_shape]:
                dx, dy = ddxy
                board[curx+dx][cury+dy] = cur_shape
            curx, cury = nx, ny+1
            ans += CHARMAP[cur_shape]
            # print(curx,cury)
            # printBoard(board)
            # print("----------------------------------")
            cur_shape = (cur_shape) % 6 + 1 # next shape
        pass
    print("%d. %s"%(TEST_CASE+1, ans))
